package Logic;


import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Vector;
import ocsf.server.*;
import DataBase.*;
import DataObjects.Menu;
import DataObjects.MessageGetDetailsDiscountOfTableReply;
import DataObjects.RecipeLeftList;
import DataObjects.RecipeRightList;
import DataObjects.StandardMenuRightList;
import Messages.*;


/**
 * This class Responsible to assign tasks to the server according to the Message it gets
 * from the Client
 * 
 * @author Andrey
 * @author Igor
 */

public class TaskAssignment {
	
	ArrayList<Object> arrObj = null;
	
	/**
	 * 
	 * @param msg - The message to be dealt with
	 * @param client - The client who sent the message
	 * @throws IllegalArgumentException
	 * @throws IllegalAccessException
	 * @throws SQLException
	 * @throws IOException
	 */
	
	public TaskAssignment(Object msg,ConnectionToClient client) throws IllegalArgumentException, IllegalAccessException, SQLException, IOException
	{
		Message baseMessage = (Message) msg;
		switch (baseMessage.getMessageType()){
		
		case MESSAGE_LOGIN :
		{
			
			   MessageLogin MsgLog=(MessageLogin) baseMessage;
			 			   
			   // check if username and pass are correct in database
			   //and send back corresponding message
			   
			   try {
			    LoginCheck logC=new LoginCheck(MsgLog.getUsername(),MsgLog.getPassword());			   
			    logC.Check();	
			    MessageLoginReply reply = new MessageLoginReply(logC.GetLoginStatus(),logC.GetErrorMessage(),logC.getLoginUser());			 
			    client.sendToClient(reply);			 
			   } catch (IOException e) {
			    // TODO Auto-generated catch block
			    e.printStackTrace();
			   }
			   
			  } break;
	 
		
		
		case MESSAGE_LOGOUT:
		{
			MessageLogout msgLO = (MessageLogout) baseMessage;
			Logout l = new Logout();
			l.LogoutUserFromDB(msgLO.getUsername());
			
			client.sendToClient("Logged out");
		}break;
		
		
		case MESSAGE_ADD_NEW_EMPLOYEE:
		{
			MessageAddNewEmployee msgNewEmp = (MessageAddNewEmployee) baseMessage;
			AddEmployee addEmp = new AddEmployee(msgNewEmp.getEmployee());
			addEmp.saveNewEmp();
			MessageSavingReply msgres=new MessageSavingReply(addEmp.getStatus());
			client.sendToClient(msgres);
		}break;
		

		case MESSAGE_SHOW_ALL_EMPLOYEES:
		{
		//	MessageShowAllEmployees msgNewEmp = (MessageShowAllEmployees) baseMessage;
			GetAllEmployees getEmp = new GetAllEmployees();
			Vector<Vector> result=getEmp.get();
			MessageShowAllEmployeesReply msgShowAllEmpReply=new MessageShowAllEmployeesReply(result);
			client.sendToClient(msgShowAllEmpReply);
		}break;

		
		
		case MESSAGE_SHOW_ALL_SUPPLIERS:
		{
			GetAllSuppliers getSupp = new GetAllSuppliers();
			Vector<Vector> resultSupp=getSupp.getSupp();
			MessageShowAllSuppliersReply msgShowAllSuppReply=new MessageShowAllSuppliersReply(resultSupp);
			client.sendToClient(msgShowAllSuppReply);
		}break;
		
		case MESSAGE_ADD_NEW_SUPPLIER:
		{
			MessageAddNewSupplier msgNewSupp= (MessageAddNewSupplier) baseMessage;
			AddSupplier addSupp = new AddSupplier(msgNewSupp.getSupplier());
			addSupp.saveNewSupp();
			MessageSavingReply msgres=new MessageSavingReply(addSupp.getStatus());
			client.sendToClient(msgres);
		}break;
		
		case MESSAGE_GET_SUPPLIER_BY_ID:
		{
			MessageGetSupplierById msgGetSupp= (MessageGetSupplierById) baseMessage;
			GetSupplierById getSupp = new GetSupplierById(msgGetSupp.getSuppId());
			//getSupp.getSupplierById();
			MessageGetSupplierByIdReply msgres=new MessageGetSupplierByIdReply(getSupp.getSupplierById());
			client.sendToClient(msgres);
		}break;
		
		case MESSAGE_SHOW_ID_SUPPLIER_MAX:
		{
			GetSuppId getID = new GetSuppId();
			String resultID = getID.getSuppID();
			MessageShowSupplierIDReply msgShowAIDSuppReply=new MessageShowSupplierIDReply(resultID);
			client.sendToClient(msgShowAIDSuppReply);
		}break;
		
		case MESSAGE_SHOW_ID_EMPLOYEE_MAX:
		{
			GetEmpId getID = new GetEmpId();
			String resultID = getID.getEmpID();
			MessageShowEmployeeIDReply msgShowAIDEmpReply=new MessageShowEmployeeIDReply(resultID);
			
			client.sendToClient(msgShowAIDEmpReply);
			
		}break;
		
		case MESSAGE_DELETE_SUPPLIER:
		{
			MessageDeleteSupplier msgDelSupp = (MessageDeleteSupplier) baseMessage;
			DeleteSupplier delSup = new DeleteSupplier(msgDelSupp.getSupID());
			delSup.deleteSupp();
			//MessageShowSupplierIDReply msgShowAIDSuppReply=new MessageShowSupplierIDReply(resultID);
			//client.sendToClient(msgShowAIDSuppReply);
		}break;
		
		
		case MESSAGE_DELETE_EMPLOYEE:
		{
			MessageDeleteEmployee msgDelEmp = (MessageDeleteEmployee) baseMessage;
			DeleteEmployee delEmp = new DeleteEmployee(msgDelEmp.getSupID());
			delEmp.deleteEmp();
			//MessageShowSupplierIDReply msgShowAIDSuppReply=new MessageShowSupplierIDReply(resultID);
			//client.sendToClient(msgShowAIDSuppReply);
		}break;
		

		
		
		
		case MESSAGE_CHECK_USERNAME:
		{
			MessageCheckUsername msgCheckUsername= (MessageCheckUsername) baseMessage;
			CheckUsername checkUsername=new CheckUsername(msgCheckUsername.getUsername());
			MessageCheckUsernameReply checkUsernameReply=new MessageCheckUsernameReply(checkUsername.check());
			client.sendToClient(checkUsernameReply);
		}break;
		
		
		case MESSAGE_ADD_ITEM_TO_SUPPLIER:
		{
			MessageAddItemToSupp msgAddItemToSupp = (MessageAddItemToSupp) baseMessage;
			AddItemToSupplier items_supp = new AddItemToSupplier(msgAddItemToSupp.getItemAndPrice());
			items_supp.saveNewItemToSupp();
			MessageSavingReply msgAddItemToSuppreply=new MessageSavingReply(items_supp.getStatus());
			client.sendToClient(msgAddItemToSuppreply);
			
		}break;
		
		
		case MESSAGE_REMOVE_ITEM_FROM_SUPPLIER:
		{
			MessageRemoveItemFromSupplier msgRemove = (MessageRemoveItemFromSupplier) baseMessage;
			RemoveItemFromSupplier items_supp = new RemoveItemFromSupplier(msgRemove.getItemId(),msgRemove.getSuppId());
			items_supp.removeItemFromSupp();
			MessageSavingReply msgRemovepreply=new MessageSavingReply(items_supp.getStatus());
			client.sendToClient(msgRemovepreply);
			
		}break;
		

		
		case MESSAGE_GET_MENU_TABLE_DETAILS:
		{
			GetMenuTableDetails getAllMenu = new GetMenuTableDetails();
			Vector<Menu> resultMenu=getAllMenu.getMenuTable();
			MessageGetMenuTableReply msgShowAllMenu=new MessageGetMenuTableReply(resultMenu);
			client.sendToClient(msgShowAllMenu);
		}break;
		
		
		case MESSAGE_GET_RECIPES_TO_RIGHT_LIST_FOR_UPD_STANDMENU:
		{
			MessageGetRecipesToRightListForUpdStandMenu msgNoMenu = (MessageGetRecipesToRightListForUpdStandMenu) baseMessage;
			GetRecipesToRightListForUpdStandMenu getRecipes = new GetRecipesToRightListForUpdStandMenu(msgNoMenu.getNoMenu(),msgNoMenu.getFlag());
			Vector<StandardMenuRightList> resultRecipes=getRecipes.getRecipesOfMenu();
			MessageGetRecipesToRightListForUpdStandMenuReply msgShowAllRecipesReply=new MessageGetRecipesToRightListForUpdStandMenuReply(resultRecipes);
			client.sendToClient(msgShowAllRecipesReply);
		}break;

		
		
		case MESSAGE_GET_USER_BY_ID:
		{
			MessageGetUserById msgGetUser= (MessageGetUserById) baseMessage;
     		GetUserById getUser=new GetUserById(msgGetUser.getEid());
			MessageGetUserByIdReply msgGetUserReply=new MessageGetUserByIdReply(getUser.get());
			
			client.sendToClient(msgGetUserReply);
		}break;
		
		case MESSAGE_UPDATE_EMPLOYEE:
		{
			MessageUpdateEmployee msgUpdEmp = (MessageUpdateEmployee) baseMessage;
			UpdateEmployee updEmp = new UpdateEmployee(msgUpdEmp.getEmployee());
			updEmp.updateEmp();
			MessageSavingReply msgres=new MessageSavingReply(updEmp.getStatus());
			client.sendToClient(msgres);
		}break;
		
		
		case MESSAGE_GET_ALL_ITEMS:
		{
			MessageGetAllItems msgAllItems = (MessageGetAllItems) baseMessage;
			GetItems getItems = new GetItems(msgAllItems.getSuppId());
			MessageGetAllItemsReply msgAllItemsReply=new MessageGetAllItemsReply(getItems.getAllItems());
			client.sendToClient(msgAllItemsReply);
		}break;
		
		
		
		case MESSAGE_GET_ALL_SUPPLIER_ITEMS:
		{
			MessageGetAllSupplierItems msgAllSupItems = (MessageGetAllSupplierItems) baseMessage;
			GetItems getItems = new GetItems(msgAllSupItems.getSuppId());
			MessageGetSupplierItemsReply msgAllSupItemsReply=new MessageGetSupplierItemsReply(getItems.getSupItems());
			client.sendToClient(msgAllSupItemsReply);
		}break;
		
		
		case MESSAGE_UPDATE_ITEMS_OF_SUPPLIER:
		{
			MessageUpdateItemsOfSupplier msgUpdItems = (MessageUpdateItemsOfSupplier) baseMessage;
			UpdateItemsOfSupplier updateItems = new UpdateItemsOfSupplier(msgUpdItems.getUpdates());
			updateItems.updateItems();
			MessageSavingReply msgres=new MessageSavingReply(updateItems.getStatus());
			client.sendToClient(msgres);
		}break;
		
		
		
		case MESSAGE_UPDATE_SUPPLIER:
		{
			MessageUpdateSupplier msgUpdSupp = (MessageUpdateSupplier) baseMessage;
			UpdateSupplier updateSupp = new UpdateSupplier(msgUpdSupp.getSupplier());
			updateSupp.update();
			MessageSavingReply msgres=new MessageSavingReply(updateSupp.getStatus());
			client.sendToClient(msgres);
		}break;
		
		

		case MESSAGE_GET_ALL_RECIPES:
		{
			GetRecipesForNewMenu getRecipes = new GetRecipesForNewMenu();
			MessageGetAllRecipesReply msgAllItemsReply=new MessageGetAllRecipesReply(getRecipes.getMenuRecipes());
			client.sendToClient(msgAllItemsReply);
			}break;

		case MESSAGE_GET_RECIPES_TO_LEFT_LIST_FOR_ADD_BUSSMENU:
		{
			GetRecipesToLeftListForNewBusinessMenu getRecipes = new GetRecipesToLeftListForNewBusinessMenu();
			MessageGetRecipesToLeftListForAddBussMenuReply msgAllItemsReply=new MessageGetRecipesToLeftListForAddBussMenuReply(getRecipes.getMenuRecipes());
			client.sendToClient(msgAllItemsReply);
			}break;
			
		case MESSAGE_GET_ITEMS_BY_CATEGORY:
		{
			MessageGetItemsByCategory msgItemsByCategory = (MessageGetItemsByCategory) baseMessage;
			GetItemsByCategory getItems = new GetItemsByCategory(msgItemsByCategory.getCategory(),msgItemsByCategory.getSuppId());
			MessageGetItemsByCategoryReply msgItemsByCategoryReply=new MessageGetItemsByCategoryReply(getItems.getAllItems(),getItems.getSuppItems());
			client.sendToClient(msgItemsByCategoryReply);
		}break;
		

		

		case MESSAGE_SHOW_ID_MENU_MAX:
		{
			GetMenuOrRecipeID getID = new GetMenuOrRecipeID();
			String resultID = getID.getMenuID();
			MessageShowIdMenuReply msgShowIDMenuReply=new MessageShowIdMenuReply(resultID);
			client.sendToClient(msgShowIDMenuReply);
		}break;
			

		case MESSAGE_SHOW_ID_STANDARD_MENU_MAX:
		{
			GetMenuOrRecipeID getID = new GetMenuOrRecipeID();
			String resultID = getID.getStandardMenuID();
			MessageShowIdStandardMenuReply msgShowIDMenuReply=new MessageShowIdStandardMenuReply(resultID);
			client.sendToClient(msgShowIDMenuReply);
		}break;
		
		
		case MESSAGE_ADD_NEW_BUSINESS_MENU:
		{
			MessageAddNewBusinessMenu msgAddNewBusinessMenu = (MessageAddNewBusinessMenu) baseMessage;
			AddNewBusinessMenu menu_details = new AddNewBusinessMenu(msgAddNewBusinessMenu.getMenuDetails(),msgAddNewBusinessMenu.getMenuDetails1());
			menu_details.saveNewBusinessMenu();
			MessageSavingReply msgSaveMenuReply=new MessageSavingReply(menu_details.getStatus());
			client.sendToClient(msgSaveMenuReply);
		}break;
		
		case MESSAGE_ADD_NEW_STANDARD_MENU:
		{
			MessageAddNewStandardMenu msgAddNewBusinessMenu = (MessageAddNewStandardMenu) baseMessage;
			AddNewStandardMenu menu_details = new AddNewStandardMenu(msgAddNewBusinessMenu.getMenuDetails(),msgAddNewBusinessMenu.getMenuDetails1());
			menu_details.saveNewStandardMenu();
			MessageSavingReply msgSaveMenuReply=new MessageSavingReply(menu_details.getStatus());
			client.sendToClient(msgSaveMenuReply);
		}break;
		
		case MESSAGE_SHOW_ALL_MENUS:
		{
			GetAllMenus getMenu = new GetAllMenus();
			Vector<Vector> resultMenu=getMenu.getMenu();
			MessageShowBusinessMenusReply msgShowAllMenusReply=new MessageShowBusinessMenusReply(resultMenu);
			client.sendToClient(msgShowAllMenusReply);
		}break;
		
		case MESSAGE_SHOW_ALL_STANDARDS_MENUS:
		{
			GetAllMenus getMenu = new GetAllMenus();
			Vector<Vector> resultMenu=getMenu.getStandardMenu();
			MessageShowAllStandardsMenusReply msgShowAllMenusReply=new MessageShowAllStandardsMenusReply(resultMenu);
			client.sendToClient(msgShowAllMenusReply);
		}break;
		
		case MESSAGE_GET_RECIPES_TO_LEFT_LIST_FOR_UPD_STANDMENU:
		{
			MessageGetRecipesToLeftListForUpdStandMenu msgMenuID = (MessageGetRecipesToLeftListForUpdStandMenu) baseMessage;
			GetRecipes getRecipes = new GetRecipes(msgMenuID.getMenuId());
			MessageGetRecipesToLeftListForUpdStandMenuReply msgAllRecipesReply=new MessageGetRecipesToLeftListForUpdStandMenuReply(getRecipes.getAllRecipes());
			client.sendToClient(msgAllRecipesReply);
		}break;
		
		case MESSAGE_GET_RECIPES_TO_LEFT_LIST_FOR_UPD_BUSSMENU:
		{
			MessageGetRecipesToLeftListForUpdBussMenu msgMenuID = (MessageGetRecipesToLeftListForUpdBussMenu) baseMessage;
			GetRecipesToLeftListForUpdBussMenu getRecipes = new GetRecipesToLeftListForUpdBussMenu(msgMenuID.getMenuId());
			MessageGetRecipesToLeftListForUpdBussMenuReply msgAllRecipesReply=new MessageGetRecipesToLeftListForUpdBussMenuReply(getRecipes.getAllRecipes());
			client.sendToClient(msgAllRecipesReply);
		}break;
		
		case MESSAGE_GET_RECIPES_TO_RIGHT_LIST_FOR_UPD_BUSSMENU:
		{
			MessageGetRecipesToRightListForUpdBussMenu msgMenuID = (MessageGetRecipesToRightListForUpdBussMenu) baseMessage;
			GetAllRecipesOfThisMenu getRecipes = new GetAllRecipesOfThisMenu(msgMenuID.getNoMenu(),msgMenuID.getFlag());
			MessageGetRecipesToRightListForUpdBussMenuReply msgAllRecipesReply=new MessageGetRecipesToRightListForUpdBussMenuReply(getRecipes.getRecipesOfMenu());
			client.sendToClient(msgAllRecipesReply);
		}break;
		
		case MESSAGE_UPDATE_STANDARD_MENU:
		{
			MessageUpdateStandardMenu msgUpdateCurrMenu = (MessageUpdateStandardMenu) baseMessage;
			UpdateStandardMenu menu_details = new UpdateStandardMenu(msgUpdateCurrMenu.getMenuDetails(),msgUpdateCurrMenu.getMenuDetails1());
			menu_details.saveNewStandardMenu();
			MessageSavingReply msgUpdateMenuReply=new MessageSavingReply(menu_details.getStatus());
			client.sendToClient(msgUpdateMenuReply);
		}break;
		
		case MESSAGE_UPDATE_BUSINESS_MENU:
		{
			MessageUpdateBusinessMenu msgUpdateCurrMenu = (MessageUpdateBusinessMenu) baseMessage;
			UpdateCurrentMenu menu_details = new UpdateCurrentMenu(msgUpdateCurrMenu.getMenuDetails(),msgUpdateCurrMenu.getMenuDetails1());
			menu_details.saveNewBusinessMenu();
			MessageSavingReply msgUpdateMenuReply=new MessageSavingReply(menu_details.getStatus());
			client.sendToClient(msgUpdateMenuReply);
		}break;
		
		
		case MESSAGE_DELETE_BUSINESS_MENU:
		{
			MessageDeleteBusinessMenu msgDelMenu = (MessageDeleteBusinessMenu) baseMessage;
			DeleteMenu delMenu = new DeleteMenu(msgDelMenu.getMenuID());
			delMenu.deleteMenu();
			
		}break;
		
		
		/*case MESSAGE_SHOW_ALL_RECIPES_THAT_CAN_BUY:
		{
			MessageShowAllRecipesThatCanBuy msgRes = (MessageShowAllRecipesThatCanBuy) baseMessage;
			GetRecipes getRecipes = new GetRecipes(msgRes.getMenID());
		//	Vector<Vector> resultRecipes=getRecipes.getRecipesOfMenu1();
			//MessageShowAllRecipesThatCanBuyReply msgShowAllRecipesReply=new MessageShowAllRecipesThatCanBuyReply(resultRecipes);
		//	client.sendToClient(msgShowAllRecipesReply);
		}break;*/
		

		case MESSAGE_SHOW_ID_RECIPE_MAX:
		{
			GetMenuOrRecipeID getID = new GetMenuOrRecipeID();
			String resultID = getID.getRecipeID();
			MessageShowIDRecipeReply msgShowIDRecipeReply=new MessageShowIDRecipeReply(resultID);
			client.sendToClient(msgShowIDRecipeReply);
		}break;
		
		case MESSAGE_GET_ALL_ITEMS_FOR_NEW_RECIPE:
		{
			GetAllItemsForNewRecipe getItems = new GetAllItemsForNewRecipe();
			MessageGetAllItemsForNewRecipeReply msgAllItemsReply=new MessageGetAllItemsForNewRecipeReply(getItems.getItems());
			client.sendToClient(msgAllItemsReply);
			}break;
		
		case MESSAGE_GET_ITEMS_THAT_NOT_IN_THIS_RECIPE:
		{
			MessageGetItemsThatNotInThisRecipe msgNoRecipe = (MessageGetItemsThatNotInThisRecipe) baseMessage;
			GetAllItemsOfThisRecipe getRecipes = new GetAllItemsOfThisRecipe(msgNoRecipe.getRecipeId());
			Vector<RecipeLeftList> resultRecipes=getRecipes.getAllItems();
			MessageGetItemsThatNotInThisRecipeReply msgShowAllItemsReply=new MessageGetItemsThatNotInThisRecipeReply(resultRecipes);
			client.sendToClient(msgShowAllItemsReply);
		}break;
			
		case MESSAGE_GET_ITEMS_OF_EXISTING_RECIPE:
		{
			MessageGetItemsOfExistingRecipe msgNoMenu = (MessageGetItemsOfExistingRecipe) baseMessage;
			GetAllItemsOfThisRecipe getRecipes = new GetAllItemsOfThisRecipe(msgNoMenu.getNoRecipe());
			Vector<RecipeRightList> resultRecipes=getRecipes.getItemsOfRecipe();
			MessageGetItemsOfExistingRecipeReply msgShowAllItemsReply=new MessageGetItemsOfExistingRecipeReply(resultRecipes);
			client.sendToClient(msgShowAllItemsReply);
		}break;
		
		case MESSAGE_UPDATE_CURRENT_RECIPE:
		{
			MessageUpdateCurrentRecipe msgUpdateRecipe = (MessageUpdateCurrentRecipe) baseMessage;
			UpdateCurrentRecipe recipe_details = new UpdateCurrentRecipe(msgUpdateRecipe.getRecipeItemsDetails(),msgUpdateRecipe.getRecipeDetails());
			recipe_details.updateRecipe();
			MessageSavingReply msgAddRecipeReply=new MessageSavingReply(recipe_details.getStatus());
			client.sendToClient(msgAddRecipeReply);
		}break;
		
		case MESSAGE_DELETE_RECIPE:
		{
			MessageDeleteRecipe msgDelRecipe = (MessageDeleteRecipe) baseMessage;
			DeleteRecipe delMenu = new DeleteRecipe(msgDelRecipe.getRecID());
			delMenu.deleteRecipe();
			
		}break;
		
		case MESSAGE_GET_ITEMS_BY_CATEGORY_FOR_NEW_RECIPE:
		{
			MessageGetItemsByCategoryForNewRecipe msgItemsByCategory = (MessageGetItemsByCategoryForNewRecipe) baseMessage;
			GetAllItemsByCategoryForNewRecipe getItems = new GetAllItemsByCategoryForNewRecipe(msgItemsByCategory.getCategory());
			MessageGetItemsByCategoryForNewRecipeReply msgItemsByCategoryReply=new MessageGetItemsByCategoryForNewRecipeReply(getItems.getAllItems());
			client.sendToClient(msgItemsByCategoryReply);
		}break;
		
		case MESSAGE_GET_PRICE_ITEM_FROM_OUR_SUPPLIER:
		{
			MessageGetPriceItemByNameItem msgPriceItemByNameItem = (MessageGetPriceItemByNameItem) baseMessage;
			GetPriceItemByItemName getPriceItem = new GetPriceItemByItemName(msgPriceItemByNameItem.getNameItem());
			MessageGetPriceItemByNameItemReply msgItemsByCategoryReply=new MessageGetPriceItemByNameItemReply(getPriceItem.getPriceItem());
			client.sendToClient(msgItemsByCategoryReply);
		}break;
		
		case MESSAGE_ADD_NEW_RECIPE_TO_DATA_BASE:
		{
			MessageAddRecipeToDataBase msgAddNewRecipe = (MessageAddRecipeToDataBase) baseMessage;
			AddNewRecipeToDataBase recipe_details = new AddNewRecipeToDataBase(msgAddNewRecipe.getRecipeDetails(),msgAddNewRecipe.getRecipeDetails1());
			recipe_details.saveNewRecipe();
			MessageSavingReply msgAddRecipeReply=new MessageSavingReply(recipe_details.getStatus());
			client.sendToClient(msgAddRecipeReply);
		}break;
		
		case MESSAGE_GET_COST_RECIPE_BY_NAME:
		{
			MessageGetCostRecipeByName msgPriceRecipeByNameRecipe = (MessageGetCostRecipeByName) baseMessage;
			GetCostRecipeByName getPriceItem = new GetCostRecipeByName(msgPriceRecipeByNameRecipe.getNameRecipe());
			MessageGetCostRecipeByNameReply msgItemsByCategoryReply=new MessageGetCostRecipeByNameReply(getPriceItem.getPriceRecipe());
			client.sendToClient(msgItemsByCategoryReply);
		}break;
		
		
		/*case MESSAGE_ADD_COMMENT_TO_EMP_WORK_HRS:
		{
            MessageAddCommentAboutOverHrs msgAddCommentAboutOverHrs= (MessageAddCommentAboutOverHrs)baseMessage;
			
			
			System.out.println("--msgAddCommentAboutOverHrs.getEmpDetails()---");
			System.out.println(msgAddCommentAboutOverHrs.getEmpDetails());
			
			AddCommentAboutOverHrs  commentAboutOverHrs = new AddCommentAboutOverHrs(msgAddCommentAboutOverHrs.getEmpDetails());
			System.out.println("msgAddCommentAboutOverHrs.getEmpDetails()");
			System.out.println(msgAddCommentAboutOverHrs.getEmpDetails());
			commentAboutOverHrs.saveComment();
			
			
		}break;*/
		
		/*case MESSAGE_ADD_WORKING_HOURS:
		{
			MessageAddWorkingHours msgAddNewWorkingHours = (MessageAddWorkingHours) baseMessage;
			System.out.println("MESSAGE_ADD_WORKING_HOURS1");
			System.out.println("msgAddNewWorkingHours.getEmpDetails()");
			System.out.println(msgAddNewWorkingHours.getEmpDetails());
			System.out.println(msgAddNewWorkingHours.getEmpDetails().get(3));
			
			System.out.println("--------------");
			
			
			if(msgAddNewWorkingHours.getEmpDetails().get(9).isEmpty() ) 
			{
				
			}
			AddNewWorkingHoursOfEmployee workHoursDetails = new AddNewWorkingHoursOfEmployee(msgAddNewWorkingHours.getEmpDetails());
			System.out.println("msgAddNewWorkingHours.getEmpDetails()");
			System.out.println(msgAddNewWorkingHours.getEmpDetails());
			
			System.out.println("MESSAGE_ADD_WORKING_HOURS2");
			workHoursDetails.saveNewHours();
			System.out.println("MESSAGE_ADD_WORKING_HOURS3");
			
			MessageSavingReply msgAddHoursReply=new MessageSavingReply(workHoursDetails.getStatus());
			System.out.println("MessageSavingReply msgAddHoursReply=new MessageSavingReply(workHoursDetails.getStatus());");
			System.out.println(workHoursDetails.getStatus());
			System.out.println(">>>>>>>>>>>....");
			System.out.println(msgAddHoursReply.getResult());
			client.sendToClient(msgAddHoursReply);                       //  dalshe idet obriv client server pri peredache na clienta
			
			System.out.println("proverochka");
			System.out.println(workHoursDetails.getworkHours());
		//	System.out.println("workHoursDetails.getStatus()"+ workHoursDetails.getworkHours().get(8)!="null");
		 	if (!workHoursDetails.getworkHours().get(8).equals("null"))           // pri Exit button nujno podschitat kol-vo chasov, a pri enter net 
		  {
			workHoursDetails.calculateHours();
			MessageAddWorkingHoursReply msgAddWorkingHoursReply = new MessageAddWorkingHoursReply(workHoursDetails.getTotalTodayWorkHours(),workHoursDetails.getTotalMonthWorkHours());
		
			System.out.println("--workHoursDetails.getTotalTodayWorkHours()----");
			System.out.println(workHoursDetails.getTotalTodayWorkHours());
			
			client.sendToClient(msgAddWorkingHoursReply);
		  }
			 
		 
			System.out.println("end of MESSAGE_ADD_WORKING_HOURS");
			
		}break;*/
		
	/*	
		case MESSAGE_SAVING_REPLY:
		{
			
			MessageSavingReply msgSavingReply=(MessageSavingReply)baseMessage;
			System.out.println("yeaaaaaaaaaaaah!");
			
			// dugma vnizu
			// MessageReturnDecisionAboutButtonEnterOrExitReply getDecisionAbouButton=new MessageReturnDecisionAboutButtonEnterOrExitReply(msgReturnDecision.getFlagButton());
			//  	client.sendToClient(getDecisionAbouButton);
			}break;
		*/
		
/*		case MESSAGE_GET_WORKING_HOURS:
		{
			MessageAddWorkingHours msgAddNewWorkingHours = (MessageAddWorkingHours) baseMessage;
			AddNewWorkingHoursOfEmployee workHoursDetails = new AddNewWorkingHoursOfEmployee(msgAddNewWorkingHours.getEmpDetails());
			workHoursDetails.saveNewHours();
			MessageSavingReply msgAddHoursReply=new MessageSavingReply(workHoursDetails.getStatus());
			client.sendToClient(msgAddHoursReply);
			workHoursDetails.calculateHours();
			MessageAddWorkingHoursReply msgAddWorkingHoursReply = new MessageAddWorkingHoursReply(workHoursDetails.getTotalTodayWorkHours(),workHoursDetails.getTotalMonthWorkHours());
		
			System.out.println("--workHoursDetails.getTotalTodayWorkHours()----");
			System.out.println(workHoursDetails.getTotalTodayWorkHours());
			
			client.sendToClient(msgAddWorkingHoursReply);
			
		}break;  */
		
		
		//--------------------------------------------------------------
		
	/*	case MESSAGE_ADD_COMMENT_TO_EMP_WORK_HRS:       //dodelat
		{
			MessageAddCommentAboutOverHrs messageAddCommentAboutOverHrs = (MessageAddCommentAboutOverHrs)baseMessage;
			AddCommentAboutOverHrs addCommentAboutOverHrs = new AddCommentAboutOverHrs();
		
		//	MessageSavingReply msgAddHoursReply=new MessageSavingReply(workHoursDetails.getStatus());
		//	client.sendToClient(msgAddHoursReply);
			
		}break;*/
		
		
		//--------------------------------------------------------------
		
		
		
	/*	case MESSAGE_GET_WORK_HOURS_BY_ID_EMPLOYEE_REPLY:
		{
			MessageShowAllWorkHours msgGetWorkingHours = (MessageShowAllWorkHours) baseMessage;
			GetWorkHoursByIdEmployee workHoursDetails = new GetWorkHoursByIdEmployee(msgGetWorkingHours.getEmpId(),msgGetWorkingHours.getThisMonth());
			MessageShowAllWorkHoursReply msgGetHoursReply = new MessageShowAllWorkHoursReply(workHoursDetails.getWorkHoursById());
		    client.sendToClient(msgGetHoursReply);
		}break;*/
		//--------------------------------
	
	
		
	
	
	

		
		case MESSAGE_GET_ALL_TELEPHONE_ORDERS_FOR_DATE:
		{
			MessageGetAllTelephoneOrdersForDate msgOrders = (MessageGetAllTelephoneOrdersForDate) baseMessage;
			GetTelephoneOrders getTelOrders = new GetTelephoneOrders(msgOrders.getDate());
			Vector<Vector> resultOrders=getTelOrders.getOrdersForDate();
			MessageGetAllTelephoneOrdersForDateReply msgOrdersReply=new MessageGetAllTelephoneOrdersForDateReply(resultOrders);
			client.sendToClient(msgOrdersReply);
		}break;
		
		case MESSAGE_ADD_NEW_TELEPHONE_ORDER:
		{
			MessageAddNewTelephoneOrder msgOrder = (MessageAddNewTelephoneOrder) baseMessage;
			AddNewTelephoneOrder getTelOrders = new AddNewTelephoneOrder(msgOrder.getOrder());
			getTelOrders.saveNewOrder();
			MessageSavingReply msgres=new MessageSavingReply(getTelOrders.getStatus());
			client.sendToClient(msgres);
		}break;
		
		
		case MESSAGE_GET_ID_FOR_NEW_TELEPHONE_ORDER:
		{
			GetTelephoneOrderID getID = new GetTelephoneOrderID();
			String resultID = getID.getMenuID();
			MessageGetIdForNewTelephoneOrderReply msgGetIDReply=new MessageGetIdForNewTelephoneOrderReply(resultID);
			client.sendToClient(msgGetIDReply);
		}break;
		
		
		case MESSAGE_UPDATE_TABLE_OF_TELEPHONE_ORDER:
		{
			MessageUpdateTableOfTelephoneOrder msgUpd= (MessageUpdateTableOfTelephoneOrder) baseMessage;
			UpdateTelephoneOrders updTel=new UpdateTelephoneOrders(msgUpd.getValue(),msgUpd.getOrderId());
			if(msgUpd.getFieldToUpdate().equals("status"))			
				updTel.updateStatus();
			
			if(msgUpd.getFieldToUpdate().equals("restTable"))
				updTel.updateTable();
			
		}break;
		
		
		case MESSAGE_UPDATE_TELEPHONE_ORDER:
		{
			MessageUpdateTelephoneOrder msgUpd= (MessageUpdateTelephoneOrder) baseMessage;
			UpdateTelephoneOrders updTel=new UpdateTelephoneOrders(msgUpd.getOrder());
			updTel.updateOrder();
			MessageSavingReply msgres=new MessageSavingReply(updTel.getStatus());
			client.sendToClient(msgres);
			
			
		}break;
		
		
		

		
		case MESSAGE_CHECK_SCHEDULE_IF_EXISTS:
		{
			MessageCheckScheduleIfExists msgCheck= (MessageCheckScheduleIfExists) baseMessage;
			CheckScheduleIfExists checkSchedule=new CheckScheduleIfExists(msgCheck.getName());
			checkSchedule.check();
			MessageCheckScheduleIfExistsReply msgres=new MessageCheckScheduleIfExistsReply(checkSchedule.getResult());
			client.sendToClient(msgres);						
		}break;
		
		
		
		case MESSAGE_SAVE_NEW_SCHEDULE:
		{
			MessageSaveNewSchedule msgSaveSchedule= (MessageSaveNewSchedule) baseMessage;
			SaveNewTablesSchedule saveSchedule=new SaveNewTablesSchedule(msgSaveSchedule.getTables());
			saveSchedule.save();
			MessageSavingReply msgres=new MessageSavingReply(saveSchedule.getStatus());
			client.sendToClient(msgres);
			
			
		}break;
		

		
		case MESSAGE_UPDATE_SCHEDULE:
		{
			MessageUpdateSchedule msgUpdateSchedule= (MessageUpdateSchedule) baseMessage;
			CheckScheduleIfExists checkSchedule=new CheckScheduleIfExists(msgUpdateSchedule.getTables().get(0).get(5));
			checkSchedule.check();
			if (checkSchedule.getResult()==0) 
			{
				SaveNewTablesSchedule saveSchedule=new SaveNewTablesSchedule(msgUpdateSchedule.getTables());
				saveSchedule.save();
				MessageSavingReply msgres=new MessageSavingReply(saveSchedule.getStatus());
				client.sendToClient(msgres);
			}
			else
			{
				UpdateTablesSchedule updateSchedule=new UpdateTablesSchedule(msgUpdateSchedule.getTables());
				updateSchedule.update();
				MessageSavingReply msgres=new MessageSavingReply(updateSchedule.getStatus());
				client.sendToClient(msgres);
			}
			
			
		}break;
		
		
		case MESSAGE_GET_ALL_SCHEDULES:
		{
			GetAllSchedules getSchedules=new GetAllSchedules();
			getSchedules.get();
			MessageGetAllSchedulesReply msgres=new MessageGetAllSchedulesReply(getSchedules.getSchedules());
			client.sendToClient(msgres);			
			
		}break;
		
		
		case MESSAGE_GET_STATUS_OF_ALL_TABLES:
		{
			GetStatusOfAllTables getStatus=new GetStatusOfAllTables();
			getStatus.get();
			MessageGetStatusOfAllTablesReply msgres=new MessageGetStatusOfAllTablesReply(getStatus.getResTableStatus());
			client.sendToClient(msgres);		
			
		}break;
		
		
		case MESSAGE_GET_ALL_MENUES:
		{
			MessageGetAllMenues msgUpdateSchedule= (MessageGetAllMenues) baseMessage;
			GetAllMenuesAndOrdersForATable getAllMenuesAndOrdersForATable=new GetAllMenuesAndOrdersForATable(msgUpdateSchedule.getTableNo());
			getAllMenuesAndOrdersForATable.recieveMenues();
			getAllMenuesAndOrdersForATable.recieveRecipes();
			MessageGetAllMenuesReply msgres=new MessageGetAllMenuesReply(getAllMenuesAndOrdersForATable.getMenues(),getAllMenuesAndOrdersForATable.getVecBon(),getAllMenuesAndOrdersForATable.getMetadataOrder());
			client.sendToClient(msgres);		
			
		}break;
		
		
		case MESSAGE_GET_REPORT_WAITERS_BY_DATE:
		{
			MessageGetReportWaitersByDate msgGetReport=(MessageGetReportWaitersByDate)baseMessage;
			GetWaitersReportByDate getReport=new GetWaitersReportByDate(msgGetReport.getFromData(),msgGetReport.getToData());
			MessageGetReportWaitersByDateReply msgRes=new MessageGetReportWaitersByDateReply(getReport.getReportOfWaiters());
			client.sendToClient(msgRes);		
			
		}break;
		
		case MESSAGE_GET_REPORT_WAITER_THIS_BY_DATE:
		{
			MessageGetReportOnTablesOfWaiter msgGetReport=(MessageGetReportOnTablesOfWaiter)baseMessage;
			GetReportOnTablesOfWaiter getReport=new GetReportOnTablesOfWaiter(msgGetReport.getFromData(),msgGetReport.getToData(),msgGetReport.getWaiterID());
			MessageGetReportOnTablesOfWaiterReply msgRes=new MessageGetReportOnTablesOfWaiterReply(getReport.getReportTablesOfWaiterThis());
			client.sendToClient(msgRes);		
			
		}break;

		case MESSAGE_GET_REPORT_WORK_HOURS_OF_WAITER:
		{
			MessageGetReportWorkHoursOfWaiter msgGetReport=(MessageGetReportWorkHoursOfWaiter)baseMessage;
			GetReportOnWorkHoursOfWaiter getReport=new GetReportOnWorkHoursOfWaiter(msgGetReport.getFromData(),msgGetReport.getToData(),msgGetReport.getWaiterID());
			MessageGetReportWorkHoursOfWaiterReply msgRes=new MessageGetReportWorkHoursOfWaiterReply(getReport.getReportTablesOfWaiterThis());
			client.sendToClient(msgRes);		
			
		}break;
		
		case MESSAGE_SAVE_TABLE_ORDER:
		{
			MessageSaveTableOrder msgSaveTableOrder=(MessageSaveTableOrder)baseMessage;
			SaveTableOrder saveOrder=new SaveTableOrder(msgSaveTableOrder.getBones(),msgSaveTableOrder.getMetaDataOrder());
			saveOrder.saveOrder();
			MessageSavingReply msgSaveTableOrderReply=new MessageSavingReply(saveOrder.getStatus());
			client.sendToClient(msgSaveTableOrderReply);		
			
		}break;
		
		case MESSAGE_CLOSE_TABLE:
		{
			MessageCloseTable msgCloseTable=(MessageCloseTable)baseMessage;
			CloseTable closeTable=new CloseTable(msgCloseTable.getBones(),msgCloseTable.getMetaDataOrder());
			closeTable.closeTable();
			MessageSavingReply msgSaveTableOrderReply=new MessageSavingReply(closeTable.getStatus());
			client.sendToClient(msgSaveTableOrderReply);		
			
		}break;
		

	case MESSAGE_SHOW_ALL_INVENTORY:
	{
		GetAllInventory getInv = new GetAllInventory();
		Vector<Vector> resultInv = getInv.getAll();
		MessageShowAllInventoryReply msgShowAllInvReply = new MessageShowAllInventoryReply(resultInv);
		client.sendToClient(msgShowAllInvReply);
		
	}break;
	
	case MESSAGE_SHOW_ID_INVENTORY_ITEM:
	{
		GetLastItemId getID = new GetLastItemId();
		String ID = getID.getID();
		MessageShowIDInventoryItemReply msgShowAllInvReply = new MessageShowIDInventoryItemReply(ID);
		client.sendToClient(msgShowAllInvReply);
	}break;
	
	case MESSAGE_GET_ITEMS_CATEGORIES:
	{
		GetCategories cats = new GetCategories();
		Vector<String> categories = cats.getAll();
		MessageGetItemsCategoriesReply msgCategories = new MessageGetItemsCategoriesReply(categories);
		client.sendToClient(msgCategories);
	}break;
	
	
	case MESSAGE_ADD_NEW_INVENTORY_ITEM:
	{
		MessageAddNewInventoryItem msgAddItem = (MessageAddNewInventoryItem)baseMessage;
		AddNewInventoryItem processor = new AddNewInventoryItem(msgAddItem.getItem());
		MessageAddNewInventoryItemReply msgRes = new MessageAddNewInventoryItemReply(processor.saveItem());
		client.sendToClient(msgRes);
		
	}break;
	
	case MESSAGE_CHECK_EXISTS_ITEM:
	{
		MessageCheckExistsItems msgCheckItem = (MessageCheckExistsItems)baseMessage;
		CheckExistsItem processor = new CheckExistsItem(msgCheckItem.getItem());
		MessageCheckExistsItemsReply msgRes = new MessageCheckExistsItemsReply(processor.checkExistItem());
		client.sendToClient(msgRes);
		
	}break;
	

	
	case MESSAGE_GET_ITEM_BY_ID:{
		MessageGetItemByID msgGetItem = (MessageGetItemByID)baseMessage;
		GetItemById processor = new GetItemById(msgGetItem.id);
		MessageGetItemByIDReply msgRes = new MessageGetItemByIDReply(processor.getItem());
		client.sendToClient(msgRes);
	}break;
	
	case MESSAGE_ADD_NEW_ORDER:{
		MessageAddNewOrder msgAdd = (MessageAddNewOrder)baseMessage;
		AddNewOrder processor = new AddNewOrder(msgAdd.getOrders());
		MessageAddNewOrderReply msgRes = new MessageAddNewOrderReply(processor.Add());
		client.sendToClient(msgRes);
	}break;
	
	case MESSAGE_GET_SUPPLIERS_FOR_ITEM:
	{
		MessageGetSuppliersForItem msgSuppsForItem = (MessageGetSuppliersForItem)baseMessage;
		GetSuppliersForItem getter = new GetSuppliersForItem(msgSuppsForItem.getItemId());
		MessageGetSuppliersForItemReply msgReply = new MessageGetSuppliersForItemReply(getter.getSuppliers());
		client.sendToClient(msgReply);
		
	}break;
	
	
	case MESSAGE_GET_ORDERS:{
		MessageGetOrders msgGet = (MessageGetOrders)baseMessage;
		GetOrders data = new GetOrders(msgGet.get_searchFields());
		MessageGetOrdersReply response = new MessageGetOrdersReply(data.get());
		client.sendToClient(response);
	}break;
	

	case MessageGetItemsForOrder:{
		MessageGetItemsForOrder msgGet = (MessageGetItemsForOrder)baseMessage;
		GetItemsForOrder data = new GetItemsForOrder(msgGet.getOrder_id());
		MessageGetItemsForOrderReply response = new MessageGetItemsForOrderReply(data.getOrders());
		client.sendToClient(response);
	}break;
	
	
	
	case  MESSAGE_GET_FIRES_BY_ORDERID:{
		
		MessageGetFiresByOrderid msgGet=(MessageGetFiresByOrderid)baseMessage;
		GetFiresByOrderId getFires=new GetFiresByOrderId(msgGet.getOrderId());
		MessageGetFiresByOrderidReply msgGetReply=new MessageGetFiresByOrderidReply(getFires.getFires());
		client.sendToClient(msgGetReply);
	}break;
	
	
	case  MESSAGE_SAVE_FIRES:{
		
		MessageSaveFires msgSaveFires=(MessageSaveFires)baseMessage;
		SaveFires save=new SaveFires(msgSaveFires.getFires());
		MessageSavingReply msgSavingFiresReply=new MessageSavingReply(save.save());
		client.sendToClient(msgSavingFiresReply);
	}break;
	
case  MESSAGE_GET_FIRED_RECIPES:{
		
		MessageGetFiredRecipes msgSaveFires=(MessageGetFiredRecipes)baseMessage;
		GetFiredRecipes get=new GetFiredRecipes();
		MessageGetFiredRecipesReply msgGetFiredRecipesReply=new MessageGetFiredRecipesReply(get.getFiredRecipes());
		client.sendToClient(msgGetFiredRecipesReply);
	}break;
	
	
	
case  MESSAGE_SUBMIT_FIRE:{
	
	MessageSubmitFire msgSubmit=(MessageSubmitFire)baseMessage;
	SubmitFire submit=new SubmitFire(msgSubmit.getSubmit());
	MessageSavingReply msgSaveSubmitReply=new MessageSavingReply(submit.submit());
	client.sendToClient(msgSaveSubmitReply);
}break;
	
case MESSAGE_ADD_COMMENT_TO_EMP_WORK_HRS:
{
    MessageAddCommentAboutOverHrs msgAddCommentAboutOverHrs= (MessageAddCommentAboutOverHrs)baseMessage;
	 
	AddCommentAboutOverHrs  commentAboutOverHrs = new AddCommentAboutOverHrs(msgAddCommentAboutOverHrs.getEmpDetails(),msgAddCommentAboutOverHrs.getFlagHrs());
	 	commentAboutOverHrs.saveComment();
	
	
}break;

case MESSAGE_REMOVE_COMMENT_FROM_EMP_WORK_HRS:
{
    MessageRemoveCommentAboutOverHrs msgRemoveCommentAboutOverHrs= (MessageRemoveCommentAboutOverHrs)baseMessage;
	RemoveCommentAboutOverHrs  commentAboutOverHrs = new RemoveCommentAboutOverHrs(msgRemoveCommentAboutOverHrs.getEmpDetails());
	    commentAboutOverHrs.saveComment();
	
	
}break;

case MESSAGE_ADD_WORKING_HOURS:
{   
	MessageAddWorkingHours msgAddNewWorkingHours = (MessageAddWorkingHours) baseMessage;
	 
	AddNewWorkingHoursOfEmployee workHoursDetails = new AddNewWorkingHoursOfEmployee(msgAddNewWorkingHours.getEmpDetails());
	 
	workHoursDetails.saveNewHours(); 
	MessageSavingReply msgAddHoursReply=new MessageSavingReply(workHoursDetails.getStatus()); 
	client.sendToClient(msgAddHoursReply);                                 
	 
 	if (!workHoursDetails.getworkHours().get(5).equals("null"))  // pri Exit button nujno podschitat kol-vo chasov, a pri enter net 
  {  
    workHoursDetails.clocksAndHours();  		 		
	workHoursDetails.calculateHours();
	MessageAddWorkingHoursReply msgAddWorkingHoursReply = new MessageAddWorkingHoursReply(workHoursDetails.getTotalTodayWorkHours(),workHoursDetails.getTotalMonthWorkHours(), workHoursDetails.getdatesHours());
 
	client.sendToClient(msgAddWorkingHoursReply);
  }
 
}break;

case MESSAGE_GET_WORK_HOURS_BY_ID_EMPLOYEE:
{
	MessageShowAllWorkHours msgGetWorkingHours = (MessageShowAllWorkHours) baseMessage;
	
	GetWorkHoursByIdEmployee workHoursDetails = new GetWorkHoursByIdEmployee(msgGetWorkingHours.getEmpId(),msgGetWorkingHours.getThisMonth());
	
	MessageShowAllWorkHoursReply msgGetHoursReply = new MessageShowAllWorkHoursReply(workHoursDetails.getWorkHoursById());
	 
	client.sendToClient(msgGetHoursReply);
}break;

case MESSAGE_CHECK_EXISTS_EMPLOYEE_FOR_CLOCK_IN_OUT:
{
	MessageCheckExistsEmpForClockInOut msgCheckUserID= (MessageCheckExistsEmpForClockInOut) baseMessage;
	CheckExistsEmployee checkUserID=new CheckExistsEmployee(msgCheckUserID.getUserID());
	checkUserID.Check();
	MessageCheckExistsEmpForClockInOutReply checkUserIDReply=new MessageCheckExistsEmpForClockInOutReply(checkUserID.getUser(),checkUserID.getIDEmp(),checkUserID.getPermission());
	client.sendToClient(checkUserIDReply);
}break;

case MESSAGE_RETURN_DECISION_ABOUT_BUTTON_ENTER_OR_EXIT:
{
	MessageReturnDecisionAboutButtonEnterOrExit msgReturnDecision= (MessageReturnDecisionAboutButtonEnterOrExit) baseMessage;
	GetDecisionAboutButtonEnterOrExit getDecision=new GetDecisionAboutButtonEnterOrExit(msgReturnDecision.getEmpID(),msgReturnDecision.getDate());
	getDecision.CheckAndSave();
	MessageReturnDecisionAboutButtonEnterOrExitReply getDecisionAbouButton=new MessageReturnDecisionAboutButtonEnterOrExitReply(getDecision.getFlag());
	client.sendToClient(getDecisionAbouButton);
}break;

case MESSAGE_RETURN_DECISION_ABOUT_BUTTON_ENTER_OR_EXIT_REPLY:
{
	MessageReturnDecisionAboutButtonEnterOrExitReply msgReturnDecision= (MessageReturnDecisionAboutButtonEnterOrExitReply) baseMessage;
	 
	    MessageReturnDecisionAboutButtonEnterOrExitReply getDecisionAbouButton=new MessageReturnDecisionAboutButtonEnterOrExitReply(msgReturnDecision.getFlagButton());
  	client.sendToClient(getDecisionAbouButton);
}break;

case MESSAGE_ADD_OR_UPDATE_WORKING_HOURS_FROM_DOH:
{
	MessageAddOrUpdateWorkingHoursFromDoh msgHours = (MessageAddOrUpdateWorkingHoursFromDoh) baseMessage;
	UpdateWorkingHoursOfEmployee updWorkHours = new UpdateWorkingHoursOfEmployee(msgHours.getEmpHours());
	updWorkHours.saveNewHours();
	
	MessageSavingReply msgres=new MessageSavingReply(updWorkHours.getStatus());
	
	client.sendToClient(msgres);
	updWorkHours.calculateHours();

	MessageAddWorkingHoursReply msgAddWorkingHoursReply = new MessageAddWorkingHoursReply(updWorkHours.getTotalTodayWorkHours(),updWorkHours.getTotalTodayWorkHours(), null);
	 //  vajno proverit null!!!!
	client.sendToClient(msgAddWorkingHoursReply);
	
	 
}break;

case MESSAGE_ADD_NEW_PAYMENT_OF_TABLE:
{
	MessageAddNewPaymentOfTable msgHours = (MessageAddNewPaymentOfTable) baseMessage;
	AddNewPaymentOfTable payment = new AddNewPaymentOfTable (msgHours.getPay());
	payment.savePaymentOfTable();
	MessageSavingReply msgSaveSubmitReply=new MessageSavingReply(payment.getStatus());
	client.sendToClient(msgSaveSubmitReply);
	
	 
}break;

case MESSAGE_GET_PAYMENT_DETAILS_BY_ORDERID:
{
	MessageGetPaymentDetailsByOrderID msgOrderID = (MessageGetPaymentDetailsByOrderID) baseMessage;
	GetPaymentDetailsByOrderID payment = new GetPaymentDetailsByOrderID (msgOrderID.getOrderID());
	MessageGetPaymentDetailsByOrderIDReply msgOrderDetailsReply=new MessageGetPaymentDetailsByOrderIDReply(payment.getPaymentDetails());
	client.sendToClient(msgOrderDetailsReply);
	
	 
}break;


case MESSAGE_CHECK_BALANCE_PRESENT_CARD:
{
	MessageCheckBalancePresentCard msgPresCard = (MessageCheckBalancePresentCard) baseMessage;
	CheckBalancePresentCard payment = new CheckBalancePresentCard (msgPresCard.getNumCard());
	MessageCheckBalancePresentCardReply msgPresCardReply=new MessageCheckBalancePresentCardReply(payment.getBalance());
	client.sendToClient(msgPresCardReply);
	
	 
}break;
		
case MESSAGE_ADD_NEW_DISCOUNT_TO_TABLE:
{
	MessageAddDiscount msgHours = (MessageAddDiscount) baseMessage;
	AddNewDiscountToTable addDiscount = new AddNewDiscountToTable (msgHours.getDiscount());
	addDiscount.saveNewDiscount();
	MessageSavingReply msgSaveSubmitReply=new MessageSavingReply(addDiscount.getStatus());
	client.sendToClient(msgSaveSubmitReply);
	
	 
}break;

case MESSAGE_DELETE_DISCOUNT_FROM_TABLE:
{
	MessageDeleteDiscount msgDelete= (MessageDeleteDiscount)baseMessage;
	DeleteDiscountFromTable  deleteDiscount = new DeleteDiscountFromTable(msgDelete.getOrderID());
	deleteDiscount.deleteDiscount();
	MessageSavingReply msgSaveSubmitReply=new MessageSavingReply(deleteDiscount.getStatus());
	client.sendToClient(msgSaveSubmitReply);	
}break;

case MESSAGE_GET_DETAILS_DISCOUNT_OF_TABLE:
{
	MessageGetDetailsDiscountOfTable msgOrderID = (MessageGetDetailsDiscountOfTable) baseMessage;
	GetDetailsDiscountOfTable payment = new GetDetailsDiscountOfTable (msgOrderID.getId());
	MessageGetDetailsDiscountOfTableReply msgOrderDetailsReply=new MessageGetDetailsDiscountOfTableReply(payment.getDetails());
	client.sendToClient(msgOrderDetailsReply);
}break;

case MESSAGE_CHECK_EXISTS_PRESENT_CARD:
{
	MessageCheckExistPresentCard msgCheckCard = (MessageCheckExistPresentCard)baseMessage;
	CheckExistPresentCard processor = new CheckExistPresentCard(msgCheckCard.getCardNum());
	MessageCheckExistPresentCardReply msgRes = new MessageCheckExistPresentCardReply(processor.checkExistPresentCard());
	client.sendToClient(msgRes);
	
}break;

case MESSAGE_SHOW_ALL_TABLES_OF_THIS_SHIFT:
{
	//MessageShowAllTablesOfThisShift msgOrderID = (MessageShowAllTablesOfThisShift) baseMessage;
	GetAllTablesOfShift table = new GetAllTablesOfShift ();
	MessageShowAllTablesOfThisShiftReply msgTableDetailsReply=new MessageShowAllTablesOfThisShiftReply(table.getTablesOfShift());
	client.sendToClient(msgTableDetailsReply);
}break;


case MESSAGE_SAVE_COMMENTS_FOR_A_TABLE:
{
	MessageSaveCommentsForATable msgSaveComments=(MessageSaveCommentsForATable)baseMessage;
	SaveCommentsForATable saveCommentsForATable=new SaveCommentsForATable(msgSaveComments.getMetaDataOrder());
	MessageSavingReply msgSaveSubmitReply=new MessageSavingReply(saveCommentsForATable.save());
	client.sendToClient(msgSaveSubmitReply);
}break;







				default:
		{
			
		}
		}				
	}
}
